<?php /* SVN: $Id: admin_index.ctp 6080 2010-11-03 06:09:48Z sakthivel_135at10 $ */ ?>
<div class="userPaypalConnections index js-response">
    <ul class="filter-list record-info clearfix js-pagination">
		<?php $class = (!empty($this->request->params['named']['is_active']) && $this->request->params['named']['is_active'] ==1) ? ' status_selected' : null; ?>
		<li><span class="active round-5">
		<?php echo $this->Html->link(sprintf(__l('Active: %s'),$this->Html->cInt($active_count,false)), array('controller'=>'user_paypal_connections','action'=>'index','is_active' => 1), array('class' => $class, 'title' => sprintf(__l('Active: %s'),$this->Html->cInt($active_count,false))));?></span></li>

		<?php $class = (!empty($this->request->params['named']['is_active']) && $this->request->params['named']['is_active'] == 0) ? ' status_selected' : null; ?>
		<li><span class="inactive round-5"><?php echo $this->Html->link(sprintf(__l('Inactive: %s'),$this->Html->cInt($inactive_count,false)), array('controller'=>'user_paypal_connections','action'=>'index','is_active' => 0), array('class' => $class, 'title' => sprintf(__l('Inactive: %s'),$this->Html->cInt($inactive_count,false))));?></span></li>
    </ul>

<div class="page-count-block clearfix">
	    <div class="grid_left">
	      <?php echo $this->element('paging_counter'); ?>
		</div>
		<div class="grid_left">
            <?php echo $this->Form->create('UserPaypalConnection', array('type' => 'get', 'class' => 'normal search-form', 'action'=>'index')); ?>
                       <?php echo $this->Form->input('q', array('label' => __l('Keyword'))); ?>
            			<?php echo $this->Form->submit(__l('Search'));?>
            <?php echo $this->Form->end(); ?>
		</div>
  </div>
<div class="content-info"><?php echo __l('If you want to delete any of the connections, you can click the Inactive link.
It will deactivate the connection. It will not displayed in User side, where as it will displayed here for your reference.');?></div>
<table class="list">
    <tr>
        <th rowspan="2" class="actions"><?php echo __l('Actions');?></th>
        <th rowspan="2"><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Created On'), 'created');?></div></th>
        <th rowspan="2"><div class="js-pagination"><?php echo $this->Paginator->sort(__l('User'), 'User.username');?></div></th>
        <th rowspan="2"><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Sender email'), 'sender_email');?></div></th>
        <th rowspan="2"><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Pre Approval Key'), 'pre_approval_key');?></div></th>
        <th colspan="2"><?php echo __l('Validity'); ?></th>
        <th colspan="2"><?php echo __l('Amount'); ?></th>
		<th rowspan="2"><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Purchase Count'), 'charged_count');?></div></th>
        <th rowspan="2"><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Default?'), 'is_default');?></div></th>
    </tr>
    <tr>
        <th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('From'), 'valid_from');?></div></th>
        <th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('To'), 'valid_to');?></div></th>
        <th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Total'), 'amount');?></div></th>
        <th><div class="js-pagination"><?php echo $this->Paginator->sort(__l('Charged'), 'charged_amount');?></div></th>        
    </tr>
<?php
if (!empty($userPaypalConnections)):

$i = 0;
foreach ($userPaypalConnections as $userPaypalConnection):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
	if($userPaypalConnection['UserPaypalConnection']['is_active']):
		$class = ' class="active-record"';
	else:
		$class = ' class="inactive-record"';
	endif;
?>
	<tr<?php echo $class;?>>
			<td class="actions dl">
            <div class="action-block">
                <span class="action-information-block">
                    <span class="action-left-block">&nbsp;&nbsp;</span>
                        <span class="action-center-block">
                            <span class="action-info">
                                <?php echo __l('Action');?>
                             </span>
                        </span>
                    </span>
                    <div class="action-inner-block">
                    <div class="action-inner-left-block">
                        <ul class="action-link clearfix">
            <?php if($userPaypalConnection['UserPaypalConnection']['is_active']) : ?>
                <li><?php echo $this->Html->link(__l('Inactive'), array('action' => 'delete', $userPaypalConnection['UserPaypalConnection']['id']), array('class' => 'delete js-delete', 'title' => __l('Click to inactivate this PayPal connection')));?></li>
            <?php else : ?>
                <li><?php echo $this->Html->link(__l('Active'), array('controller'=> 'user_paypal_connections', 'action' => 'active', $userPaypalConnection['UserPaypalConnection']['id']), array('class' => 'icon-active js-delete', 'title' => __l('Click active to activate PayPal connection')));?></li>
			<?php endif; ?>
                        		 </ul>
    					</div>
    					<div class="action-bottom-block"></div>
    				  </div>
              </div>
        </td>
		<td><?php echo $this->Html->cDateTimeHighlight($userPaypalConnection['UserPaypalConnection']['created']);?></td>
		<td><?php echo $this->Html->link($this->Html->cText($userPaypalConnection['User']['username']), array('controller'=> 'users', 'action'=>'view', $userPaypalConnection['User']['username'], 'admin' => false), array('escape' => false));?></td>
		<td><?php echo $this->Html->cText($userPaypalConnection['UserPaypalConnection']['sender_email']);?></td>
		<td><?php echo $this->Html->cText($userPaypalConnection['UserPaypalConnection']['pre_approval_key']);?></td>
		<td><?php echo $this->Html->cDate($userPaypalConnection['UserPaypalConnection']['valid_from']);?></td>
		<td><?php echo $this->Html->cDate($userPaypalConnection['UserPaypalConnection']['valid_to']);?></td>
		<td><?php echo Configure::read('site.currency').$this->Html->cCurrency($userPaypalConnection['UserPaypalConnection']['amount']);?></td>
		<td><?php echo Configure::read('site.currency').$this->Html->cCurrency($userPaypalConnection['UserPaypalConnection']['charged_amount']);?></td>
		<td><?php echo $this->Html->link($this->Html->cInt($userPaypalConnection['UserPaypalConnection']['charged_count']), array('controller'=> 'project_funds', 'action'=>'index', 'user_paypal_connection_id' => $userPaypalConnection['UserPaypalConnection']['id'] , 'admin' => true), array('escape' => false));?></td>
		<td><?php echo $this->Html->cBool($userPaypalConnection['UserPaypalConnection']['is_default']);?></td>
	</tr>
<?php
    endforeach;
else:
?>
	<tr>
		<td colspan="14" class="notice"><?php echo __l('No PayPal Connections available');?></td>
	</tr>
<?php
endif;
?>
</table>

<?php
if (!empty($userPaypalConnections)):?>
<div class="js-pagination">
  <?php  echo $this->element('paging_links'); ?>
</div>  
<?php endif;?>

</div>
